{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ArbitraryOutlierCapper\n",
    "The ArbitraryOutlierCapper() caps the maximum or minimum values of a variable\n",
    "at an arbitrary value indicated by the user.\n",
    "\n",
    "The user must provide the maximum or minimum values that will be used <br>\n",
    "to cap each variable in a dictionary {feature : capping_value}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# importing libraries\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "from feature_engine.outliers import ArbitraryOutlierCapper"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load titanic dataset from OpenML\n",
    "\n",
    "def load_titanic():\n",
    "    data = pd.read_csv(\n",
    "        'https://www.openml.org/data/get_csv/16826755/phpMYEkMl')\n",
    "    data = data.replace('?', np.nan)\n",
    "    data['cabin'] = data['cabin'].astype(str).str[0]\n",
    "    data['pclass'] = data['pclass'].astype('O')\n",
    "    data['embarked'].fillna('C', inplace=True)\n",
    "    data['fare'] = data['fare'].astype('float')\n",
    "    data['fare'].fillna(data['fare'].median(), inplace=True)\n",
    "    data['age'] = data['age'].astype('float')\n",
    "    data['age'].fillna(data['age'].median(), inplace=True)\n",
    "    data.drop(['name', 'ticket'], axis=1, inplace=True)\n",
    "    return data\n",
    "\n",
    "# To plot histogram of given numerical feature\n",
    "\n",
    "\n",
    "def plot_hist(data, col):\n",
    "    plt.figure(figsize=(8, 5))\n",
    "    plt.hist(data[col], bins=30)\n",
    "    plt.title(\"Distribution of \" + col)\n",
    "    return plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pclass</th>\n",
       "      <th>survived</th>\n",
       "      <th>sex</th>\n",
       "      <th>age</th>\n",
       "      <th>sibsp</th>\n",
       "      <th>parch</th>\n",
       "      <th>fare</th>\n",
       "      <th>cabin</th>\n",
       "      <th>embarked</th>\n",
       "      <th>boat</th>\n",
       "      <th>body</th>\n",
       "      <th>home.dest</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>214</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>female</td>\n",
       "      <td>23.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>113.275</td>\n",
       "      <td>D</td>\n",
       "      <td>C</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Lexington, MA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>651</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>30.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7.225</td>\n",
       "      <td>n</td>\n",
       "      <td>C</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Ottawa, ON</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>930</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>28.0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>7.750</td>\n",
       "      <td>n</td>\n",
       "      <td>Q</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>992</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>female</td>\n",
       "      <td>30.5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7.750</td>\n",
       "      <td>n</td>\n",
       "      <td>Q</td>\n",
       "      <td>NaN</td>\n",
       "      <td>61</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>718</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>20.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7.050</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Portugal</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    pclass  survived     sex   age  sibsp  parch     fare cabin embarked boat  \\\n",
       "214      1         1  female  23.0      1      0  113.275     D        C    6   \n",
       "651      3         0    male  30.0      0      0    7.225     n        C  NaN   \n",
       "930      3         0    male  28.0      1      0    7.750     n        Q  NaN   \n",
       "992      3         0  female  30.5      0      0    7.750     n        Q  NaN   \n",
       "718      3         0    male  20.0      0      0    7.050     n        S  NaN   \n",
       "\n",
       "    body      home.dest  \n",
       "214  NaN  Lexington, MA  \n",
       "651  NaN     Ottawa, ON  \n",
       "930  NaN            NaN  \n",
       "992   61            NaN  \n",
       "718  NaN       Portugal  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = load_titanic()\n",
    "data.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data: (916, 11)\n",
      "test data: (393, 11)\n"
     ]
    }
   ],
   "source": [
    "# let's separate into training and testing set\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(data.drop('survived', axis=1),\n",
    "                                                    data['survived'],\n",
    "                                                    test_size=0.3,\n",
    "                                                    random_state=0)\n",
    "\n",
    "print(\"train data:\", X_train.shape)\n",
    "print(\"test data:\", X_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAZM0lEQVR4nO3de7SldX3f8fdHhoAC4SKndJwBBpVqiKsOdkRc2gRBI+AFs1ZicHmZWLImbTHRhCSCGsUuabGNktomtEQQvCHESyBIjIhkGdsKDgjIReIEBplxYAaQmxgi+O0f+zeyHWY49zm/vef9Wmuv8+zfc/v+ztn7fM7ze579nFQVkiSpD09Z6AIkSdLjDGZJkjpiMEuS1BGDWZKkjhjMkiR1xGCWJKkjBrM0B5L8ryR/PEfbOiDJQ0l2as//LslvzcW22/b+JsnKudreNPb7gSR3J7lze+9bGiXxc8zSk0uyFtgPeBR4DLgJ+DhwVlX9ZAbb+q2q+so01vk74JNV9dHp7Kuteyrw7Kp603TXnUtJDgBuAQ6sqo0LWYvUO4+Ypal5TVXtARwInA68Ezh7rneSZNFcb7MTBwD3GMrS5AxmaRqq6v6quhj4DWBlkucBJDk3yQfa9L5JLklyX5J7k/x9kqck+QSDgPrrNlT9R0mWJakkJyT5HvDVobbhkH5WkquSPJDkoiT7tH0dkWTdcI1J1iZ5eZKjgXcBv9H2d12b/9Oh8VbXe5LcnmRjko8n2bPN21zHyiTfa8PQ797W9ybJnm39TW1772nbfzlwGfCMVse5W1l37/Y925TkB2166dD8g5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uqaq72vNR7MvLgduqalNV/Rj4PIP30HZ5v4xTMI/jbUAvBla26ZUMztV2L0mAs4Gbq+rDQ7NGrj9JJpLs1aafyuBc+c0MAvrX2mLd96WqTqmqpVW1jMF746tV9UZGrB8ASXZLssfmaQbnM29gBF9fVXUncEeS57Smo4CbGMG+DHkDjw9jw2j25XvA4Ume1n6fbf65bJ/3y0KfZJ/jE/bHAv/A4Bzguxe6nmnWfj6Dcxk/ZvBX9AkMzgFeDnwX+Aqwz0LXOcW+vJTBcNX1wLXtcewo9gf418C3Wl9uAN7b2p8JXAWsYTBkt8tC1zqNPh0BXDKq/Wg1X9ceN25+r4/i66vVvRxY3V5jfwXsPcJ92Q24B9hzqG1U+/J+4Dvtff8JYJft9X7xzl+SJHVknIayJUkaeQazJEkdMZglSeqIwSxJUkcMZkmSOmIwS5LUEYNZkqSOGMySJHXk/wOn1so1cVz37wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of age feature before capping outliers\n",
    "\n",
    "plot_hist(data, 'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYCElEQVR4nO3dfbTdVZ3f8fdHAjLjA+HhmsUkgeCQ6jBdFWlq49KpSkbLgzX84TC4HIk0s9LVUqvVWU58GKtdtsV2KSN9oGWJNfiMzFgySh1jwOXMWgMaFJAHlSsFkxhIRAgCoyP67R9nXz3EhHvuzb3J5uT9Wuuss39779/vt88ml09++/e7J6kqJElSH55ysAcgSZJ+yWCWJKk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wPVr7hvaqmmve9s9c7nHpIcziCUP15Vf96qnb8ZqKoHgeuAFzJYJpy6QBien1/MXWs/Crj/wI60Gy8CXpXkbga3504HPohzN7Kq2t7edzL4S+EL6PjndtyC2a8DnZ2NwJpWXgNcPVR/fntKcSWwe2jp55DT7tNdDtxRVR8YanL+ppFkol0pk+TXgJczuEd/HfDq1m3PuZua01cD19Yh+qULVfW2qlpSVcsY/D/t2qp6Lc7dSJI8LckzpsrAK4Bb6fnntqrG6gWcBXyHwf2rdxzs8fT2Aj4J7AB+yuDeyVoG9582A3cCXwKOaX3D4Cn37wLfBFYc7PEf5Ll7MYN7VbcAN7XXWc7fSHP3D4BvtLm7FXhXq3828FVgEvgM8NRWf2Tbnmztzz7Yn6GHF/BS4HPO3Yzm7NnAze1121Qu9Pxz6zd/SZLUkXFbypYk6UnNYJYkqSMGsyRJHTGYJUnqiMEsSVJHDGZJkjpiMEuS1BGDWZKkjvx/csKUYAcL4/kAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of fare feature before capping outliers\n",
    "\n",
    "plot_hist(data, 'fare')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max age: 80.0\n",
      "Max fare: 512.3292\n",
      "Min age: 0.1667\n",
      "Min fare: 0.0\n"
     ]
    }
   ],
   "source": [
    "# let's find out the maximum&minimum Age and maximum Fare in the titanic\n",
    "print(\"Max age:\", data.age.max())\n",
    "print(\"Max fare:\", data.fare.max())\n",
    "\n",
    "print(\"Min age:\", data.age.min())\n",
    "print(\"Min fare:\", data.fare.min())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Maximum capping"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ArbitraryOutlierCapper(max_capping_dict={'age': 50, 'fare': 150})"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''Parameters\n",
    "----------\n",
    "max_capping_dict : dictionary, default=None\n",
    "    Dictionary containing the user specified capping values for the right tail of\n",
    "    the distribution of each variable (maximum values).\n",
    "\n",
    "min_capping_dict : dictionary, default=None\n",
    "    Dictionary containing user specified capping values for the eft tail of the\n",
    "    distribution of each variable (minimum values).\n",
    "\n",
    "missing_values : string, default='raise'\n",
    "    Indicates if missing values should be ignored or raised. If\n",
    "    `missing_values='raise'` the transformer will return an error if the\n",
    "    training or the datasets to transform contain missing values.\n",
    "'''\n",
    "\n",
    "# capping of age and fare features at right tail\n",
    "capper = ArbitraryOutlierCapper(\n",
    "    max_capping_dict={'age': 50, 'fare': 150}, min_capping_dict=None)\n",
    "\n",
    "capper.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum caps: {'age': 50, 'fare': 150}\n"
     ]
    }
   ],
   "source": [
    "# here we can find the maximum caps allowed\n",
    "print(\"Maximum caps:\", capper.right_tail_caps_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# this dictionary is empty, because we selected only right tail\n",
    "capper.left_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max age after capping: 50.0\n",
      "Max fare after capping: 150.0\n"
     ]
    }
   ],
   "source": [
    "# transforming train and test data\n",
    "train_t = capper.transform(X_train)\n",
    "test_t = capper.transform(X_test)\n",
    "\n",
    "#check max age and max fare after capping\n",
    "print(\"Max age after capping:\", train_t.age.max())\n",
    "print(\"Max fare after capping:\", train_t.fare.max())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Minimum capping"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ArbitraryOutlierCapper(min_capping_dict={'age': 10, 'fare': 100})"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# capping outliers at left tail\n",
    "capper = ArbitraryOutlierCapper(\n",
    "    max_capping_dict=None, min_capping_dict={'age': 10, 'fare': 100})\n",
    "\n",
    "capper.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# this dictionary is empty, because we selected only right tail\n",
    "capper.right_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 10, 'fare': 100}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# here we can find the minimum caps allowed\n",
    "capper.left_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Min age: 10.0\n",
      "Min fare: 100.0\n"
     ]
    }
   ],
   "source": [
    "# transforming train and test set\n",
    "train_t = capper.transform(X_train)\n",
    "test_t = capper.transform(X_test)\n",
    "\n",
    "# After capping\n",
    "print(\"Min age:\", train_t.age.min())\n",
    "print(\"Min fare:\", train_t.fare.min())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Both ends capping"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ArbitraryOutlierCapper(max_capping_dict={'age': 60, 'fare': 150},\n",
       "                       min_capping_dict={'age': 5, 'fare': 5})"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# capping outliers at both tails\n",
    "capper = ArbitraryOutlierCapper(\n",
    "    min_capping_dict={'age': 5, 'fare': 5},\n",
    "    max_capping_dict={'age': 60, 'fare': 150})\n",
    "capper.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 60, 'fare': 150}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# here we can find the maximum caps allowed\n",
    "capper.right_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 5, 'fare': 5}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# here we can find the minimum caps allowed\n",
    "capper.left_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max age: 60.0\n",
      "Max fare: 150.0\n",
      "Min age: 5.0\n",
      "Min fare: 5.0\n"
     ]
    }
   ],
   "source": [
    "# transforming train and test data\n",
    "train_t = capper.transform(X_train)\n",
    "test_t = capper.transform(X_test)\n",
    "\n",
    "# After capping outliers\n",
    "print(\"Max age:\", train_t.age.max())\n",
    "print(\"Max fare:\", train_t.fare.max())\n",
    "\n",
    "print(\"Min age:\", train_t.age.min())\n",
    "print(\"Min fare:\", train_t.fare.min())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "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NF6ieDefGsqqrtbfkWYNVSFtObJGuBJwCfxL66nzY9+xlgJ3A58D/AHVW1u23iI28H/hL4XeA77fWjsJ+mU8CHklzTnsAIvuemOgrYBfxDuzTy1iSPYJH6yWBeAjW4Fd7b4ZskBwLvBX6rqr4xvM6+gqq6t6qOYfAEvScDP7S0FfUnyXOBnVV1zVLXsg94alU9kcFv/zstydOGV/qeAwYfJX4i8JaqegJwN1OmrcfZTwbz4tmR5DCA9n3nEtfThSQHMAjlf6yq97Vm+2oabSrtSuApwMFJ9jyH4AGPvF2GfgL4uSRbGPw2u2cwuEZoP01RVdva953A+xn8sOd77v62Alur6pPt9XsYBPWi9JPBvHguBTa05Q3AJUtYSxfaNcDzgBuq6g1Dq+yrJsnKJAe35e8FfobBtfgrgV9omy3rPgKoqldV1eFVtZbBI4A/UlUvxH66nySPSHLQnmXgZ4Hr8D13P1V1C3Bzkh9sTccD17NI/eQDRsYgybuA4xj8xpYdwJnAPwMXA2uAm4CTqmrqDWLLSpKnAh8DPsd91wVfzeA6s30FJPkxBjeZ7MfgB+mLq+oPkzyGwcjwUODTwIuq6ltLV2k/khwHvLKqnms/3V/rj/e3l/sD76yqs5M8Ct9z95PkGAY3Ej4UuBE4hfYeZMz9ZDBLktQRp7IlSeqIwSxJUkcMZkmSOmIwS5LUEYNZkqSOGMySJHXEYJYkqSMGsyRJHfl/2rdSxJSzL0kAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of age feature after capping outliers\n",
    "plot_hist(train_t, 'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly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0b5vp64Fli3X/be/lk78kSepIr6eyJUnaKRnMkiR1xGCWJKkjBrMkSR0xmCVJ6ojBLElSRwxmSZI6YjBLktSR/w+joNFyZ/LwGAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of fare feature after capping outliers\n",
    "plot_hist(train_t, 'fare')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
